package com.smartwasser.yunhtgl.apphtgl.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.smartwasser.yunhtgl.apphtgl.base.BasePager;

import java.util.List;

public class MainAdapter extends PagerAdapter {
    public List<BasePager> mListPager;

    public MainAdapter(List<BasePager> mListPager) {
        this.mListPager = mListPager;
    }

    @Override
    public int getCount() {
        return mListPager.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
        container.removeView((View) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = mListPager.get(position).getRotorView();
        container.addView(view);
        return view;
    }
}
